<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCategoriesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // 分类表
        Schema::create('categories', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name')->comment('名称');
            $table->string('flag')->comment('标识');
            $table->unsignedBigInteger('category_group_id')->unsigned()->index()->comment('分组');
            $table->unsignedBigInteger('user_id')->comment('创建人')->index();
            $table->unsignedBigInteger('pid')->default(0)->comment('父级id 0：顶级分类')->index();
            $table->tinyInteger('status')->default(1)->comment('分类状态 0:禁用 1：启用')->index();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('categories');
    }
}
